// 苹果兼容自动播放
function init() {
  function forceSafariPlayAudio() {
    audioEl.load(); // iOS 9   还需要额外的 load 一下, 否则直接 play 无效
    audioEl.play(); // iOS 7/8 仅需要 play 一下
  }
  let audioEl = document.getElementById("bg_music");
  audioEl.addEventListener("loadstart", function () {
  }, false);
  audioEl.addEventListener("loadeddata", function () {
  }, false);
  audioEl.addEventListener("loadedmetadata", function () {
  }, false);
  audioEl.addEventListener("canplay", function () {
  }, false);
  audioEl.addEventListener(
    "play",
    function () {
      window.removeEventListener("touchstart", forceSafariPlayAudio, false);
    },
    false
  );
  audioEl.addEventListener("playing", function () {
  }, false);
  audioEl.addEventListener("pause", function () {
  }, false);
  window.addEventListener("touchstart", forceSafariPlayAudio, false);
}
export default init;